package cn.gz.ibix.ibix_library.loader;

import cn.gz.ibix.ibix_library.bean.PageBean;
import cn.gz.ibix.ibix_library.http.HttpUtil;
import cn.gz.ibix.ibix_library.http.PageConvertResponse;
import cn.gz.ibix.library.http.IConvertResponse;
import cn.gz.ibix.library.http.IHttpUtil;
import cn.gz.ibix.library.loader.BaseDataLoader;

/**
 * 项目名称：android_tool
 * <br>类描述：基础的分页数据加载器
 * <br>创建人：htliu
 * <br>创建时间：2018/4/25 16:33
 * <br>修改人:
 * <br>修改时间：2018/4/25 16:33
 * <br>修改备注：
 * <br>@version
 */

public abstract class BasePageLoaderImpl<T> extends BaseDataLoader<T> {
    @Override
    protected IHttpUtil getHttpUtil() {
        return HttpUtil.getInstance();
    }

    @Override
    protected IConvertResponse<T> getConvertResponse() {
        return
                (IConvertResponse<T>) new PageConvertResponse<T>() {
                    @Override
                    public void onError(Exception e) {

                    }

                    @Override
                    public void onSuccess(PageBean<T> result) {
                        loadSuccess(result.current(), result.total(), result.list());
                    }

                    @Override
                    public void onFail(Object result) {

                    }

                    @Override
                    public Class handleClazz() {
                        return handleClazz;
                    }
                };
    }

}
